<template>
  <md-snackbar style="top:0;margin:0px auto;" :md-duration="Infinity" :md-active="true" md-persistent>
    <span :style="'color:'+ fcolor">{{ msgcontent }}</span>
    <md-button class="md-primary" @click="closemsg">关闭</md-button>
  </md-snackbar>
</template>
<script>
import { mapActions } from 'vuex'
export default {
  props: {
    msgtype: '', // 1:success  2:error 3:warning
    msgcontent: ''
  },
  methods: {
    close: function () {
      this.$emit('onClosemsg')
    },
    ...mapActions({
      closemsg: 'onClosemsg'
    })
  },
  computed: {
    fcolor: function () {
      if (this.msgtype === 1) {
        return 'green'
      } else if (this.msgtype === 2) {
        return 'red'
      } else if (this.msgtype === 3) {
        return 'amber'
      } else {
        return 'white'
      }
    }
  }
}
</script>
